package facilius.controller.actionmanager;

import facilius.controller.ActionManager;
import facilius.controller.action.turma.TurmaCreateAction;
import facilius.controller.action.turma.TurmaDeleteAction;
import facilius.controller.action.turma.TurmaReadAction;
import facilius.controller.action.turma.TurmaShowFormAction;
import facilius.controller.action.turma.TurmaUpdateAction;
import org.mentawai.authorization.Permission;
import org.mentawai.core.ActionConfig;
import org.mentawai.core.ApplicationManager;
import org.mentawai.core.Forward;
import org.mentawai.core.Redirect;
import org.mentawai.filter.AuthorizationFilter;

/**
 *
 * @author Graciano
 */
public class TurmaActionManager implements ActionManager {

    public void loadActions(ApplicationManager appManager) {
        ActionConfig ac = null;
        ac = new ActionConfig("TurmaRead", TurmaReadAction.class);
        ac.addConsequence(appManager.SUCCESS, new Forward("jsp/turma/turmaList.page"));
        ac.addConsequence(appManager.EXCEPTION, new Forward("jsp/erro.page"));
        ac.addFilter(new AuthorizationFilter(new Permission("turma")));
        appManager.addActionConfig(ac);

        ac = new ActionConfig("TurmaShowForm", TurmaShowFormAction.class);
        ac.addConsequence(appManager.SUCCESS, new Forward("jsp/turma/turmaForm.page"));
        ac.addConsequence(appManager.ERROR, new Forward("jsp/erro.page"));
        ac.addFilter(new AuthorizationFilter(new Permission("turma")));
        appManager.addActionConfig(ac);

        ac = new ActionConfig("TurmaCreate", TurmaCreateAction.class);
        ac.addConsequence(appManager.SUCCESS, new Redirect("TurmaRead.mtw"));
        ac.addConsequence(appManager.ERROR, new Forward("jsp/erro.page"));
        ac.addFilter(new AuthorizationFilter(new Permission("turma")));
        appManager.addActionConfig(ac);

        ac = new ActionConfig("TurmaDelete", TurmaDeleteAction.class);
        ac.addConsequence(appManager.SUCCESS, new Redirect("TurmaRead.mtw"));
        ac.addConsequence(appManager.ERROR, new Forward("jsp/erro.page"));
        ac.addFilter(new AuthorizationFilter(new Permission("turma")));
        appManager.addActionConfig(ac);

        ac = new ActionConfig("TurmaUpdate", TurmaUpdateAction.class);
        ac.addConsequence(appManager.SUCCESS, new Redirect("TurmaRead.mtw"));
        ac.addConsequence(appManager.ERROR, new Forward("jsp/erro.page"));
        ac.addFilter(new AuthorizationFilter(new Permission("turma")));
        appManager.addActionConfig(ac);
    }
}
